use Mojo::mysql;
use strict;

my $mysql = Mojo::mysql->strict_mode('mysql://dahama:xxxxxxxxxx@/vpninfo');

my $db = $mysql->db;

sub show_account_info {
    my $account_infos = $db->query('select username,company_id,tibaoren,description,chuli,shijian,chuliyijian,tijiaoliyou from vpn_account where guanliyuanshenhe=0')->hashes;
    print $account_infos->[0]->{description},"\n"; #mojo render
}

sub show_mac_info {
    my $mac_infos = $db->query('select mac,company_id,tibaoren,shijian,chuli,chuliyijian,tijiaoliyou from maclist where guanliyuanshenhe=0')->hashes;
    print $mac_infos->[0]->{mac},"\n"; #mojo render
}

sub admin_deal {
    my $table = shift;
    my $shenhe = shift;
    my $mac = shift || '';
    my $username = shift || '';
    my $yijian = shift || '';
    if($table =~ /mac/){
        $db->query('update maclist set guanliyuanshenhe=?,chuiyijian=? where mac=?',$shenhe,$yijian,$mac);
    }else{
        $db->query('update vpn_account set guanliyuanshenhe=?,chuliyijian=? where username',$shenhe,$yijian,$username);
    }
    print "审批成功\n"; #mojo render
}